# -*- coding: utf-8 -*-

from osv import fields,osv
from osv.orm import browse_record
import tools
from functools import partial
import pytz
import pooler
from tools.translate import _
from service import security
import netsvc

class aas_faq(osv.osv):
    _name = 'aas.faq'
    _description = 'Câu hỏi thường gặp'
    _columns = {
        'name': fields.char('Câu hỏi', size=256, required=True),
        'content': fields.text('Trả lời', required=True),
    }
    _order = 'id desc'
aas_faq()

class aas_regulation(osv.osv):
    def function_content_short(self, cr, uid, ids, field_name, args, context=False):
        res = {}
        for obj in self.browse(cr, uid, ids, context=context):
            val = ''
            if obj.content:
                val = obj.content[:100]
                if len(obj.content) > 100:
                    val += '...'
            res[obj.id] = val
        
        return res
    
    _name = 'aas.regulation'
    _description = 'Quy chế'
    _columns = {
        'name': fields.char('Tiêu đề', size=256, required=True),
        'content': fields.text('Nội dung'),
        'content_short': fields.function(function_content_short, method=True, type='char', size=100, string='Nội dung'),
    }
    _order = 'id desc'
aas_regulation()

class aas_document(osv.osv):
    def function_content_short(self, cr, uid, ids, field_name, args, context=False):
        res = {}
        for obj in self.browse(cr, uid, ids, context=context):
            val = ''
            if obj.content:
                val = obj.content[:100]
                if len(obj.content) > 100:
                    val += '...'
            res[obj.id] = val
        
        return res
    
    _name = 'aas.document'
    _description = 'Văn bản'
    _columns = {
        'name': fields.char('Tên văn bản', size=256, required=True),
        'content': fields.text('Ghi chú'),
        'content_short': fields.function(function_content_short, method=True, type='char', size=100, string='Ghi chú'),
    }
    _order = 'id desc'
aas_document()



# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
